package com.wu.llpsw.blocks.BlockHerb;

import com.wu.llpsw.item.ModItems;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

public class yuangangguo extends CropBlock {
    public yuangangguo(Properties p_52247_) {
        super(p_52247_);
    }
    public static final IntegerProperty AGE = IntegerProperty.create("age", 0, 7);

    //每个阶段我们的作物的高低
    private static final VoxelShape[] SHAPE_BY_AGE = new VoxelShape[]{
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D),
            Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)};


    @Override
    //该作物对应哪个种子
    protected ItemLike getBaseSeedId() {
        return ModItems.zhongZiYuanGangGuo.get();//指定种子
    }


    @Override
    public VoxelShape getShape(BlockState state, BlockGetter blockgetter, BlockPos blockpos, CollisionContext contex) {
        return SHAPE_BY_AGE[state.getValue(this.getAgeProperty())];
    }

    // 获得当前的作物生长的阶段。
    @Override
    public IntegerProperty getAgeProperty() {
        return AGE;
    }

    // 获得作物最大的生长阶段。
    @Override
    public int getMaxAge() {
        return 6;
    }
    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> blockStateBuilder) {
        blockStateBuilder.add(AGE);
    }
}
